<meta http-equiv="X-UA-Compatible" content="IE=10" />
<meta content="text/html; charset=UTF-8; X-Content-Type-Options=nosniff" http-equiv="Content-Type" />
<style type="text/css">
	.appstools_panel{border-right: 1px solid #EFEFEF;  float: left;  }
	/*appstools to custom css*/
	.apps_tools_panel_functions{width: 100%; background-color: #39bf71; }

	#appstools_main_order_by_name{color: white; display: none; }
	.appstools_panel_top{color:white; text-align: center; background-color: #32a662; }
	.appstools_panel_body{background-color: #39bf71; height: 300px; }
	
	.appstools_min_panel_app_icon{display:block; margin:0 auto;}
	.appstools_min_panel_app_name_font{color:white;  text-align:center; }
	.appstools_editlist_panel_div{background-color: #39bf71; }
	.appstools_max_panel_app_name_font{color:white;}
	.appstools_max_panel_app_des_font{color:white;line-height: 12px; }
	.wp_w_55_3{width: 55.3px; } .margin_020{margin: 0 20px; }
	.wp_appstools_hand{
		 cursor:pointer;
	}
	#appstools_app_detail_window {
			border: 1px solid #EAEAEA;
	}
	.wp_mt_ne10{
		margin-top: -10px;
	}
	.wp_appstools_title{
		line-height: 20px;
	}
	.apps_tools_button{
		background-color: #32a662!important;
	}
	#apps_tools_editlist_order_by_time{color: white;}
	#apps_tools_editlist_order_by_frequent{color: white;}
	.wp_appstools_feedback{
		color: #00ffff;
	}
	.apps_tools_white_font_color{
		color: white;
	}
	.text_one_line_overflow {
     display:block;
     word-break:keep-all;
     white-space:nowrap;
     overflow:hidden;
     text-overflow:ellipsis;
     -o-text-overflow:ellipsis
  }
</style>
<style type="text/css" id='for_ipad'></style>
<div class="appstools_editlist_panel_div" id="appstools_editlist_panel"> 
	<div class="apps_tools_panel_functions wp_h_30 wp_pt_10">
		<div id="apps_tools_order_by_frequent" class="right wp_mr_20 wp_fz_10 wp_mt_2 wp_appstools_hand apps_tools_hide_button">
			Frequent
			<i id="apps_tools_order_by_frequent_i" class="main_icon_h_6_8 wp_ml_3 wp_mt_4" ></i>
		</div>
		<div id="apps_tools_order_by_time" class="right wp_mr_20 wp_fz_10 wp_mt_2 wp_appstools_hand apps_tools_hide_button">
				Time
			<i id="apps_tools_order_by_time_i" class="main_icon_h_6_8 wp_ml_3 wp_mt_4" ></i>
		</div>
	</div>
	<div id="appstools_editlist_div" data-template="appstools_editlist_template" data-bind="source:appstools_editlist_data" class="appstools_panel_body"></div>
	<div class="wp_h_30"></div>
	<div><button class="k-button wp_w_50 wp_mr_25 wp_h_20 wp_fz_12 right" type="button" data-bind="click:back">Back</button></div>
</div>

<script type="text/x-kendo-template" id="appstools_editlist_template">	
	<div class="left  wp_mb_20 wp_pl_25 wp_pr_25">
		<div class="left">
			<img class="wp_w_40 wp_h_40 wp_appstools_hand"  src="#: data.Icon #">
		</div>
		<div class="left wp_w_151 wp_ml_15 wp_mt_3">
			<div class="appstools_max_panel_app_name_font wp_fz_13 wp_mt_ne6">
				<span id="appTitle_edit" class="wp_appstools_hand text_one_line_overflow" data-bind="click:clickEdit" title="#: data.AppTitle #">#: data.AppTitle #</span>
				
			 </div>
			<!--<p class="appstools_max_panel_app_des_font wp_fz_12 wp_h_24 text_one_line_overflow" id="appDescription_edit" title="#: data.AppDescription #">#: data.AppDescription #</p>
			<div class="wp_fz_12 wp_mt_5 wp_appstools_feedback">
				<span class="left">Feedbacks:</span> 
				<div class="left wp_ml_10 wp_mt_2">
					#for(var i=0;i<5;i++){#
						#if(i<data.StarCount){#
							<i class="main_smartstream_g_10_10 wp_appstools_hand" id="starCount_edit" data-bind="click:clickFeedBack"  data-wp-tool-feedback-starcount="#:i #"></i>
						#}else{#
							<i class="main_smartstream_h_10_10 wp_appstools_hand" id="starCount_edit" data-bind="click:clickFeedBack" data-wp-tool-feedback-starcount="#:i #"></i>
						#}#
					#}#
				</div>
			</div>
			<div class="wp_fz_12 left apps_tools_white_font_color">
				<span id="launchCount_edit">#: data.LaunchCount # Users</span>
				<span>|</span>
				#if(data.IsLiked){#
					<i id="liked_edit" class="main_smartstream_t_8_8 wp_mt_5"></i>
				#}else{#
					<i id="liked_edit" class="main_smartstream_w_8_8 wp_mt_5 wp_appstools_hand" data-bind="click:clickLike"></i>
				#}# 
				<span id="likedCount_edit">(#: data.likeCount #)<span>
			</div>
			-->
		</div>
	</div>
</script>


<script>

var useragent = Workport.getBrowser();
if(useragent == 'ipad'){
	$('#for_ipad').append('#apps_tools_create_app_label_input{font-size:10px}');
	$('#for_ipad').append('#apps_tools_create_url{font-size:10px}')
}
var apps_tools_register_editlist = (function() {
	this.pageNo = 1;
	var appstools_editlist_view_model = kendo.observable({
        appstools_editlist_data :[],
        clickFeedBack:function(e){
        	console.log($(e.currentTarget).attr("data-wp-tool-feedback-starcount"));
        },
		
		clickEdit: function(e){
			alert(e.data.appId);
			appsToolsWin.apps_tools_win_create(e.data.appId);
		},

        clickLike:function(e){
        	alert("like");
        },
		back:function(e){
			editListWin.data("kendoWindow").close();
			apps_tools_register.showRegisterWin();
		}
	});

	//open home page dafault
	kendo.bind($("#appstools_editlist_panel"), appstools_editlist_view_model);
	
	var editListWin = $('#appstools_editlist_panel');
	editListWin.kendoWindow({
		width:512,
		height:400,
		title:"Edit",
		modal: true,
		visible:false,
		resizable: false,
		actions: [
			"Close"
		],
		close:function(){
			editListWin.destroy;
		}
	});
	editListWin.parent().find('#appstools_editlist_panel_wnd_title').parent().css('background-color','#32a662');
	editListWin.parent().find('#appstools_editlist_panel_wnd_title').css('color','#FFF');
	editListWin.parent().find('#appstools_editlist_panel_wnd_title').css('font-size','12px');
	
	
	var testdata=[
		{appId:"1","Icon":"imgs/icon2.png","Title":"bbbddddddddddddddddddddddddddddddddddddddb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"2","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"3","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"4","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:false,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"5","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"6","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 11ddddddddddddddddddddddddddddddd1 111 1111 1 1 11.",IsBookmarked:false,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:false},
		{appId:"7","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"8","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"9","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"10","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true},
		{appId:"11","Icon":"imgs/icon2.png","Title":"bbbb",AppDescription:"111 111 111 111 1111 1 1 11.",IsBookmarked:true,StarCount:3,LaunchCount:3,likeCount:5,IsLiked:true}
	];
	
	function getAllEditListCallback(data, httpCode){
		console.log(data);
		if(data.ResponseCode == "WP1022") {
			appstools_editlist_view_model.set("appstools_editlist_data",testdata);
			$(".appstools_editlist_panel_div").each(function(i){
				var $p = $("p", $(this)).eq(0);
				while ($p.outerHeight() > 24) {
					$p.text($p.text().replace(/(\s)*([a-zA-Z0-9]+|\W)(\.\.\.)?$/, "..."));
				};
			});
		}
	}
	
	function getEditApp(pageNo,pageSize,sort){
		var reqdata={pageNo: pageNo,pageSize:pageSize,sort:sort};
		//var reqdata={pageNo: 1,pageSize:6,sort:"ASC"};
		console.log(reqdata);
		Workport.AppAPI.getEditApp(getAllEditListCallback,reqdata);
	}
	var useragent = Workport.getBrowser();
	if(useragent == 'ipad'){
		$('#appstools_editlist_div').css('height','280px');
		$('#appstools_editlist_div').css('overflow-y','scroll');
	}else{
		$('#appstools_editlist_div').slimScroll({
			height: '280px',
			disableFadeOut:true
		});
	}
	
	
	$("#appstools_editlist_div").scroll(function(e){onDataDivScroll($(e.target));e.stopPropagation();});
	function onDataDivScroll(element){
		var n1 = parseInt(element.get(0).scrollTop);
		var n2 = parseInt(element.get(0).clientHeight);
		var n3 = parseInt(element.get(0).scrollHeight);
	
		/*
		if (n1+n2==n3&&ss_isMoved) {
			// bottom next page
			refreshListView(hideComponent,false);
			ss_isMoved = false;
		} else if(n1 == 0&&ss_isMoved) {
			// up
			refreshListView(hideComponent,true);
			ss_isMoved = false;
		}else {
			// down
			ss_isMoved = true;
		}
		*/
	};

	return {
		showEditListWin:function(){
			getEditApp(1,6,"ASC");
			editListWin.data("kendoWindow").center();
			editListWin.data("kendoWindow").open();
		}
	};
	
})();
</script>